-
Notifications
You must be signed in to change notification settings - Fork 29.1k
[SPARK-30863][SQL] Distinguish Cast and AnsiCast in toString #27608
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
|
||
| override def toString: String = s"cast($child as ${dataType.simpleString})" | ||
| override def toString: String = { | ||
| val ansi = if (ansiEnabled) "ansi" else "" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ansi_?
|
Test build #118592 has finished for PR 27608 at commit
|
|
Test build #118588 has finished for PR 27608 at commit
|
|
For better commit logs, could you put a simple example plan output before/after this pr in the description above? |
Added. Thanks! |
|
@Ngone51 can we have a JIRA? It touches many files and worth a JIRA. |
Done. |
|
Test build #118607 has finished for PR 27608 at commit
|
|
|
||
| override def toString: String = s"cast($child as ${dataType.simpleString})" | ||
| override def toString: String = { | ||
| val ansi = if (ansiEnabled) "ansi_" else "" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it should be "ansiCast" or "ANSICast" instead of "ansi_cast"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This follows the existing SQL function naming convention, e.g. FromUTCTimestamp.prettyName is from_utc_timestamp
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But the string of newInstance is newInstance($cls) ..
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NewInstance is not really a SQL function/operator...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see. It is the first expression the overrides toString with 2 words in IDE...haha
|
thanks, merging to master/3.0! |
|
Thanks all!! |
### What changes were proposed in this pull request?
Prefix by `ansi_` in `toString` if it's a `AnsiCast` or ansi enabled `Cast`.
E.g. run `spark.sql("select cast('51' as int)").queryExecution.analyzed` under ansi mode.
Before this PR:
```
Project [cast(51 as int) AS CAST(51 AS INT)#0]
+- OneRowRelation
```
After this PR:
```
Project [ansi_cast(51 as int) AS CAST(51 AS INT)#0]
+- OneRowRelation
```
### Why are the changes needed?
This is useful while comparing `LogicalPlan`s literally.
### Does this PR introduce any user-facing change?
No.
### How was this patch tested?
Pass Jenkins.
Closes #27608 from Ngone51/ansi_cast_tostring.
Authored-by: yi.wu <yi.wu@databricks.com>
Signed-off-by: Wenchen Fan <wenchen@databricks.com>
(cherry picked from commit 643a480)
Signed-off-by: Wenchen Fan <wenchen@databricks.com>
### What changes were proposed in this pull request?
Prefix by `ansi_` in `toString` if it's a `AnsiCast` or ansi enabled `Cast`.
E.g. run `spark.sql("select cast('51' as int)").queryExecution.analyzed` under ansi mode.
Before this PR:
```
Project [cast(51 as int) AS CAST(51 AS INT)#0]
+- OneRowRelation
```
After this PR:
```
Project [ansi_cast(51 as int) AS CAST(51 AS INT)#0]
+- OneRowRelation
```
### Why are the changes needed?
This is useful while comparing `LogicalPlan`s literally.
### Does this PR introduce any user-facing change?
No.
### How was this patch tested?
Pass Jenkins.
Closes apache#27608 from Ngone51/ansi_cast_tostring.
Authored-by: yi.wu <yi.wu@databricks.com>
Signed-off-by: Wenchen Fan <wenchen@databricks.com>
…st" under ANSI mode ### What changes were proposed in this pull request? Change Cast.toString as "cast" instead of "ansi_cast" under ANSI mode. This is to restore the behavior before #27608 ### Why are the changes needed? 1. There is no such a function "ansi_cast" in Spark SQL 2. Add/Divide/.. has different behavior under ANSI mode as well, but they don't have this special string representation. 3. As we are setting up new Github job for ANSI mode, this can avoid test failures from TPCDS plan stability test suites ### Does this PR introduce _any_ user-facing change? Yes but quite minor, the string output of `Cast` under ANSI mode becomes "cast" instead of "ansi_cast" again. ### How was this patch tested? Existing UT Closes #35570 from gengliangwang/revert-SPARK-30863. Authored-by: Gengliang Wang <gengliang@apache.org> Signed-off-by: Gengliang Wang <gengliang@apache.org>
What changes were proposed in this pull request?
Prefix by
ansi_intoStringif it's aAnsiCastor ansi enabledCast.E.g. run
spark.sql("select cast('51' as int)").queryExecution.analyzedunder ansi mode.Before this PR:
After this PR:
Why are the changes needed?
This is useful while comparing
LogicalPlans literally.Does this PR introduce any user-facing change?
No.
How was this patch tested?
Pass Jenkins.